function showSection(sectionId) {
    // 隐藏所有section
    document.querySelectorAll('.content-section').forEach(section => {
        section.style.display = 'none';
    });
    // 显示选中的section
    document.getElementById(sectionId).style.display = 'block';
}

// 默认显示用户管理页面
showSection('users');

// 显示添加设备表单
function showAddEquipmentForm() {
    document.getElementById('formTitle').textContent = '添加新设备';
    document.getElementById('equipmentForm').style.display = 'block';
    clearForm();
}

// 编辑设备信息
function editEquipment(equipmentId) {
    document.getElementById('formTitle').textContent = '编辑设备信息';
    document.getElementById('equipmentForm').style.display = 'block';

    // 在实际应用中，这里应该从后端获取设备信息
    // 这里仅作演示
    document.getElementById('equipmentId').value = equipmentId;
    document.getElementById('equipmentName').value = 'X光机';
    document.getElementById('equipmentDepartment').value = '放射科';
    document.getElementById('equipmentStatus').value = '正常';
    document.getElementById('equipmentNotes').value = '定期维护中';
}

// 删除设备
function deleteEquipment(equipmentId) {
    if (confirm('确定要删除该设备吗？')) {
        // 在实际应用中，这里应该调用后端API删除设备
        console.log('删除设备:', equipmentId);
    }
}

// 保存设备信息
function saveEquipment() {
    const equipmentData = {
        id: document.getElementById('equipmentId').value,
        name: document.getElementById('equipmentName').value,
        department: document.getElementById('equipmentDepartment').value,
        status: document.getElementById('equipmentStatus').value,
        notes: document.getElementById('equipmentNotes').value
    };

    // 在实际应用中，这里应该调用后端API保存设备信息
    console.log('保存设备信息:', equipmentData);

    document.getElementById('equipmentForm').style.display = 'none';
}

// 取消编辑
function cancelEdit() {
    document.getElementById('equipmentForm').style.display = 'none';
    clearForm();
}

// 清空表单
function clearForm() {
    document.getElementById('equipmentId').value = '';
    document.getElementById('equipmentName').value = '';
    document.getElementById('equipmentDepartment').value = '放射科';
    document.getElementById('equipmentStatus').value = '正常';
    document.getElementById('equipmentNotes').value = '';
}